package com.yanze.schoolinformation.view.information.relax;

import android.content.Context;
import android.content.Intent;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.yanze.schoolinformation.R;
import com.yanze.schoolinformation.adapter.vp.MyFragmentPagerAdapter;
import com.yanze.schoolinformation.base.BaseActivity;
import com.yanze.schoolinformation.databinding.ActivityRelaxBinding;
import com.yanze.schoolinformation.view.information.gank.BigAndroidFragment;
import com.yanze.schoolinformation.view.information.gank.CustomFragment;
import com.yanze.schoolinformation.view.information.gank.WanAndroidFragment;

import java.util.ArrayList;
import java.util.List;

public class RelaxActivity extends BaseActivity<ActivityRelaxBinding> {

    private List<String> mTitleList = new ArrayList<>();
    private List<Fragment> mFragments = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_relax);
        setTitle("放松");
        initFragmentList();

        MyFragmentPagerAdapter myAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), mFragments, mTitleList);
        bindingView.vpRelax.setAdapter(myAdapter);
        //左右预加载页面的个数
        bindingView.vpRelax.setOffscreenPageLimit(3);
        myAdapter.notifyDataSetChanged();
        bindingView.tabRelax.setTabMode(TabLayout.MODE_FIXED);
        bindingView.tabRelax.setupWithViewPager(bindingView.vpRelax);
        showContentView();
    }

    private void initFragmentList() {
        mTitleList.add("笑话");
        mTitleList.add("福利");
        mFragments.add(new JokeFragment());
        mFragments.add(new WelfareFragment());
    }


    public static void start(Context context) {
        context.startActivity(new Intent(context, RelaxActivity.class));
    }
}
